package com.rongke.web.api;

import com.rongke.commons.JsonResp;
import com.rongke.mapper.SysParamsMapper;
import com.rongke.model.SysParams;
import com.rongke.service.SysParamsService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;
import java.util.List;

/**
 * @SysParamsController
 * @系统参数Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/sysParams")
@Transactional
@CrossOrigin
public class SysParamsController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SysParamsService sysParamsService;

    /**
     * @添加系统参数
     * @param sysParams
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addSysParams(@RequestBody SysParams sysParams){
        log.debug("添加系统参数");
        sysParamsService.insert(sysParams);
        return JsonResp.ok(sysParams);
    }

    /**
     * @修改系统参数
     * @param sysParams
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateSysParams(@RequestBody SysParams sysParams){
        log.debug("修改系统参数");
        sysParamsService.updateById(sysParams);
        return JsonResp.ok(sysParams);
    }
    /**
     * @根据id查找系统参数
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectSysParams(Long id){
        log.debug("查找系统参数");
        SysParams sysParams = sysParamsService.selectById(id);
        return JsonResp.ok(sysParams);
    }


}
